Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

READY: DHTCommunity #3642

Merged
merged 1 commit into from
Jun 1, 2018
Merged

READY: DHTCommunity #3642

merged 1 commit into from
Jun 1, 2018

Conversation

egbertbouman
Copy link
Member

No description provided.

@xoriole
Copy link
Contributor

xoriole commented May 23, 2018

retest this please

@egbertbouman egbertbouman changed the title WIP: DHTCommunity READY: DHTCommunity May 28, 2018

_, _, payload = self._ez_unpack_auth(PingResponsePayload, data)

if not self.request_cache.has(u'request', payload.identifier):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Log an error here please.


@twisted_wrapper
def test_caching(self):
# Add a third node
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess it's easier to use https://github.com/Tribler/py-ipv8/blob/master/ipv8/test/base.py#L93, instead of creating a new MockIPv8 instance?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, I missed that function. Thanks!

yield self.nodes[0].overlay.find_values('\x00' * 20)
yield self.deliver_messages()

self.assertTrue(bool(self.nodes[1].overlay.storage.get('\x00' * 20)))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe check for the exact string instead? (self.assertEquals(...))

self.rtt = 0


class TestNode(unittest.TestCase):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please subclass from AbstractServer instead so you get additional debug features (there are some more classes in this PR who inherit from the same class).

self.assertFalse(self.bucket.owns(pad_and_convert('11')))

def test_get(self):
self.bucket.nodes[1]= 'node'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor comment: add a space before the = sign.


class TestRoutingTable(unittest.TestCase):
"""
Class to test the routing table
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please be consistent and either add a docstring under every class definition or not 👍

for bucket in self.routing_table.trie.values():
for node in bucket.nodes.values():
if node.last_response + PING_INTERVAL <= now:
deferreds.append(self.ping(node).addErrback(lambda _: None))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is correct that you do not want to do anything when a ping to a node fails?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is. When a ping fails, Node.failed will be incremented, which will eventually lead to the Node being removed from the routing table.

def lookup(self, info_hash, cb):
def callback(values):
addresses = []
for v in values:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please use a more descriptive name than v

from threading import RLock
from socket import inet_aton

import datrie
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did you check whether datrie is available in the debian repositories? Also, please update the documentation and add instructions on how to install this new dependency 👍

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yup, it's in the repositories, and I just updated the docs.

return distance(self.id, other_node.id)


class Bucket(object):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you please add a small docstring under the most important classes to explain what it represents?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

]


class DHTServiceMaker(object):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Two comments:

  • I noticed that we are reusing so much of the original Tribler plugin which leads to many different twistd plugins with duplicate code. At one point, we should merge them all together and just provide the Tribler twistd plugin (with additional parameters to run DHT/market etc).
  • When should this plugin be used?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I used it mostly for testing, but we could also use it to run DHT routers. Since we don't really need it I'm OK with removing it.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, can you remove this file then? 👍

@egbertbouman
Copy link
Member Author

retest this please

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

4 participants